var a, t = require("../../resource/js/qqmap-wx-jssdk.min.js"), e = (require("../../resource/js/config.js"), 
getApp());

Page({
    data: {
        autoplay: !0,
        interval: 3e3,
        duration: 1e3,
        showmsg: !0,
        isshow: !0,
        isuser: !0,
        isphone: !0,
        moban: 0,
        uid: 0
    },
    onShow: function(e) {
        var o = this;
        o.setData({
            isuser: o.data.isuser,
            isphone: o.data.isphone
        });
        var s = wx.getStorageSync("cityinfo");
        s ? (console.log(s.name), wx.setStorageSync("city", s.name), o.initPage()) : (a = new t({
            key: "5D3BZ-J55WF-SFPJJ-NI6PG-YN2ZO-M4BHX"
        }), wx.getLocation({
            type: "gcj02",
            success: function(t) {
                a.reverseGeocoder({
                    location: {
                        latitude: t.latitude,
                        longitude: t.longitude
                    },
                    success: function(a) {
                        var t = a.result.address_component.city, e = t.substr(0, t.length - 1);
                        wx.setStorageSync("city", e), o.initPage();
                    }
                });
            },
            fail: function() {},
            complete: function() {}
        }));
    },
    initPage: function() {
        var a = this, t = wx.getStorageSync("city");
        e.util.request({
            url: "entry/wxapp/GetSysInit",
            data: {
                city: t
            },
            success: function(t) {
                t.data.message.errno || (wx.setStorageSync("companyinfo", t.data.data.intro), wx.setStorageSync("cityinfo", t.data.data.cityinfo), 
                wx.setNavigationBarTitle({
                    title: wx.getStorageSync("companyinfo").name
                }), console.log(t.data.data.intro), t.data.data.intro.maincolor || (t.data.data.intro.maincolor = "#3274e5"), 
                wx.setNavigationBarColor({
                    frontColor: "#ffffff",
                    backgroundColor: t.data.data.intro.maincolor,
                    animation: {
                        duration: 400,
                        timingFunc: "easeIn"
                    }
                }), console.log(t.data.data.intro.isgetuser), 1 == t.data.data.intro.isgetuser ? a.setData({
                    isuser: e.globalData.isuser,
                    isphone: !0
                }) : a.setData({
                    isuser: !0,
                    isphone: !0
                }), a.setData({
                    newhouselist: t.data.data.newhouselist,
                    oldhouselist: t.data.data.oldhouselist,
                    lethouselist: t.data.data.lethouselist,
                    agentlist: t.data.data.agentlist,
                    navlist: t.data.data.navlist,
                    banners: t.data.data.banner,
                    intro: t.data.data.intro,
                    ordertype: 1,
                    moban: t.data.data.intro.moban,
                    isshow: !1,
                    isoldhouse: t.data.data.intro.isoldhouse,
                    islethouse: t.data.data.intro.islethouse,
                    isbuyhouse: t.data.data.intro.isbuyhouse,
                    issalehouse: t.data.data.intro.issalehouse,
                    isagentlethouse: t.data.data.intro.isagentlethouse,
                    isagentoldhouse: t.data.data.intro.isagentoldhouse,
                    city: wx.getStorageSync("cityinfo").name
                }));
            },
            complete: function() {
                wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
            }
        });
    },
    getPhoneNumber: function(a) {
        console.log(a.detail);
        var t = this;
        "getPhoneNumber:fail user deny" == a.detail.errMsg ? wx.showModal({
            title: "提示",
            showCancel: !1,
            content: "未授权",
            success: function(a) {}
        }) : (t.setData({
            isphone: !0
        }), e.util.request({
            url: "entry/wxapp/Getphone",
            data: {
                iv: a.detail.iv,
                encryptedData: a.detail.encryptedData,
                uid: t.data.uid
            },
            success: function(a) {
                a.data.message.errno || t.setData({
                    isphone: !0
                });
            }
        }));
    },
    bindGetUserInfo: function(a) {
        var t = this;
        e.util.getUserInfo(function(a) {
            console.log(a), t.data.isuser = !0;
            var o = a.memberInfo.uid, s = a.wxInfo.nickName, i = a.wxInfo.avatarUrl;
            t.data.uid = o, o > 0 && (t.setData({
                userinfo: a,
                isphone: !1,
                isuser: t.data.isuser
            }), e.util.request({
                url: "entry/wxapp/Updateuserinfo",
                data: {
                    uid: o,
                    nickname: s,
                    avatarUrl: i
                },
                success: function(e) {
                    e.data.message.errno || t.setData({
                        userinfo: a,
                        isphone: !1,
                        isuser: t.data.isuser
                    });
                }
            }));
        }, a.detail);
    },
    cancelUser: function(a) {
        this.data.isuser = !0, this.setData({
            isuser: this.data.isuser
        });
    },
    cancelPhone: function(a) {
        this.data.isphone = !0, this.setData({
            isphone: this.data.isphone
        });
    },
    toNagivate: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: t
        });
    },
    toSwitchtab: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.switchTab({
            url: t
        });
    },
    toWxapp: function(a) {
        var t = a.currentTarget.dataset.id, e = a.currentTarget.dataset.appid;
        console.log(t), console.log(e), wx.navigateToMiniProgram({
            appId: e,
            path: t,
            extraData: {
                foo: "bar"
            },
            envVersion: "develop",
            success: function(a) {}
        });
    },
    toStorelist: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/weixinmao_house/pages/storelist/index?id=" + t
        });
    },
    toletHouseDetail: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/weixinmao_house/pages/lethousedetail/index?id=" + t
        });
    },
    toNewHouse: function(a) {
        wx.switchTab({
            url: "/weixinmao_house/pages/newhouselist/index"
        });
    },
    toOldHouse: function(a) {
        wx.switchTab({
            url: "/weixinmao_house/pages/oldhouselist/index"
        });
    },
    toAgentlist: function(a) {
        wx.navigateTo({
            url: "/weixinmao_house/pages/agentlist/index"
        });
    },
    toArticle: function(a) {
        wx.navigateTo({
            url: "/weixinmao_house/pages/salelist/index"
        });
    },
    toActive: function(a) {
        wx.navigateTo({
            url: "/weixinmao_house/pages/active/index"
        });
    },
    toNewHouseDetail: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/weixinmao_house/pages/newhousedetail/index?id=" + t
        });
    },
    toOldHouseDetail: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/weixinmao_house/pages/oldhousedetail/index?id=" + t
        });
    },
    toLethouse: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/weixinmao_house/pages/lethouselist/index?id=" + t
        });
    },
    toMessage: function(a) {
        wx.navigateTo({
            url: "/weixinmao_house/pages/message/index"
        });
    },
    toSearch: function(a) {
        wx.navigateTo({
            url: "/weixinmao_house/pages/search/index"
        });
    },
    PubOldhouse: function(a) {
        var t = this;
        wx.navigateTo({
            url: "/weixinmao_house/pages/pub/index",
            success: function() {
                t.data.showmsg = !0, t.setData({
                    showmsg: t.data.showmsg
                });
            }
        });
    },
    PubLethouse: function(a) {
        var t = this;
        wx.navigateTo({
            url: "/weixinmao_house/pages/letpub/index",
            success: function() {
                t.data.showmsg = !0, t.setData({
                    showmsg: t.data.showmsg
                });
            }
        });
    },
    toSaleOldPub: function(a) {
        var t = this;
        wx.navigateTo({
            url: "/weixinmao_house/pages/saleoldpub/index",
            success: function() {
                t.data.showmsg = !0, t.setData({
                    showmsg: t.data.showmsg
                });
            }
        });
    },
    toSalePub: function(a) {
        var t = this;
        wx.navigateTo({
            url: "/weixinmao_house/pages/salepub/index",
            success: function() {
                t.data.showmsg = !0, t.setData({
                    showmsg: t.data.showmsg
                });
            }
        });
    },
    toSaleBuyPub: function(a) {
        var t = this;
        wx.navigateTo({
            url: "/weixinmao_house/pages/salebuypub/index",
            success: function() {
                t.data.showmsg = !0, t.setData({
                    showmsg: t.data.showmsg
                });
            }
        });
    },
    toSaleLetPub: function(a) {
        var t = this;
        wx.navigateTo({
            url: "/weixinmao_house/pages/saleletpub/index",
            success: function() {
                t.data.showmsg = !0, t.setData({
                    showmsg: t.data.showmsg
                });
            }
        });
    },
    tabClick: function(a) {
        var t = this, e = a.currentTarget.id;
        t.setData({
            ordertype: e
        });
    },
    goPub: function(a) {
        this.data.showmsg = !1, this.setData({
            showmsg: this.data.showmsg
        });
    },
    toAgentDetail: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/weixinmao_house/pages/agentdetail/index?id=" + t
        });
    },
    closemsg: function(a) {
        this.data.showmsg = !0, this.setData({
            showmsg: this.data.showmsg
        });
    },
    goMap: function(a) {
        wx.openLocation({
            latitude: parseFloat(wx.getStorageSync("companyinfo").lat),
            longitude: parseFloat(wx.getStorageSync("companyinfo").lng),
            scale: 18,
            name: wx.getStorageSync("companyinfo").name,
            address: wx.getStorageSync("companyinfo").address
        });
    },
    onReady: function() {},
    bindInput: function(a) {
        var t = this;
        this.setData({
            inputValue: a.detail.value
        }), t.onShow();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        wx.showNavigationBarLoading(), this.onLoad();
    },
    doCall: function() {
        var a = this.data.textData.shop_tel;
        wx.makePhoneCall({
            phoneNumber: a
        });
    },
    onShareAppMessage: function() {
        return {
            title: wx.getStorageSync("companyinfo").name,
            path: "/weixinmao_house/pages/index/index"
        };
    }
});